<template>
	<view>
		<view class="padding flex flex-direction">
			<button class="cu-btn margin-tb-sm lg" :class="'bg-'+theme.backgroundColor" open-type="getPhoneNumber"
				@getphonenumber="getPhoneNumber">一键登录</button>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	import api from 'utils/api'
	import validate from 'utils/validate'
	import __config from '@/config/env'; // 配置文件

	const MSGINIT = "发送验证码",
		MSGSCUCCESS = "${time}秒后可重发",
		MSGTIME = 60;
	export default {
		data() {
			return {
				theme: app.globalData.theme, //全局颜色变量
				CustomBar: this.CustomBar,
				form: {},
				msgText: MSGINIT,
				msgTime: MSGTIME,
				msgKey: false,
				showPrivacyPolicy: __config.showPrivacyPolicy,
				privacyPolicyUrl: __config.privacyPolicyUrl,
				protocolUrl: __config.protocolUrl,
			};
		},

		components: {

		},
		props: {
			reUrl: { //重定向页面
				type: String,
				default: '/pages/home/index'
			}
		},

		onLoad() {

		},

		onShow() {},
		onHide() {
			uni.removeStorageSync('drid')
		},
		onUnload() {
			uni.removeStorageSync('drid')
		},

		methods: {
			getPhoneNumber(e) {
				if (e.detail.encryptedData) {
					api.loginWxMa({
						encryptedData: e.detail.encryptedData,
						iv: e.detail.iv,
						headimgUrl: 'https://future-app.oss-cn-hangzhou.aliyuncs.com/ui-image/my_default.png'
					}).then(res => {

					})
					// api.loginByPhoneMa(e.detail).then(res => {
					// 	let userInfo = res.data;
					// 	uni.setStorageSync('third_session', userInfo.thirdSession);
					// 	uni.setStorageSync('user_info', userInfo);
					// 	const fullReUrl = uni.getStorageSync('reUrl')?  uni.getStorageSync('reUrl') : this.reUrl
					// 	//登录完成跳到首页
					// 	uni.reLaunch({
					// 	    url: decodeURIComponent(fullReUrl)
					// 	});
					// });									
				}
			}
		}
	};
</script>
<style>

</style>